<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\model;

class ShopOrderRefund extends \app\BaseModel
{
    protected $name = "card_shop_order_refund";
    protected $orer_goods_model;
    protected $append = ["goods_text", "order_text"];
    protected static function init()
    {
    }
    public function getGoodsTextAttr($value, $data)
    {
        $orer_goods_model = new ShopOrderGoods();
        $dis = !empty($data["order_goods_id"]) ? ["id" => $data["order_goods_id"]] : ["order_id" => $data["order_id"]];
        return $orer_goods_model->orderGoodsInfo($dis);
    }
    public function getOrderTextAttr($value, $data)
    {
        $orer_model = new ShopOrder();
        $dis["id"] = $data["order_id"];
        return $orer_model->orderInfo($dis);
    }
    public function refundList($dis, $page = 10)
    {
        $data = self::where($dis)->paginate($page)->toArray();
        $data["data"] = $this->changeInfo($data["data"]);
        return $data;
    }
    public function refundUpdate($dis, $data)
    {
        $data["update_time"] = time();
        $res = \think\facade\Db::name($this->name)->where($dis)->update($data);
        return $res;
    }
    public function refundInfo($dis)
    {
        $data = self::where($dis)->find()->toArray();
        return $data;
    }
    public function changeInfo($data)
    {
        if(!empty($data)) {
            foreach ($data as &$v) {
                $v["price"] = empty($v["price"]) ? $v["order_text"]["price"] : $v["price"];
                $v["goods_text"][0]["number"] = !empty($v["number"]) ? $v["number"] : $v["goods_text"][0]["number"];
            }
        }
        return $data;
    }
}

?>